<template>
  <div class="toast" v-show="isShow">
    <div>{{message}}</div>
  </div>
</template>

<script>
  export default{
    data:function(){
      return{
        isShow:false,
        message:'',
      }
    },
    methods:{
      show(message = '',duration = 1500){
          this.message = message
          this.isShow = true
        setTimeout(()=>{
          this.message = ''
          this.isShow = false
        },duration)
      }
    }
  }
</script>

<style scoped="scoped">
  .toast{
    position: fixed;
    left: 50%;
    top: 50%;
    color: white;
    text-align: center;
    width: 200px;
    padding: 10px 10px;
    transform: translate(-50%,-50%);
    background-color: rgba(0,0,0,.5);
  }
</style>
